﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using static DXApplicationTangche.UC.门店下单.form.Frm订单一览;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.销售记录.service;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.订单一览新.订单预览新.model;
using DXApplicationTangche.UC.款式异常;
using DevExpress.XtraReports.UI;
using DXApplicationTangche.report;
using DXApplicationTangche.DTO;
using DXApplicationTangche.model;
using DXApplicationTangche.UC.套号管理.套号吊牌.service;
using DXApplicationTangche.UC.套号管理.套号吊牌;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.面料库存;
using DXApplicationTangche.UC.生产计划.编排生产批.service;
using System.Net;
using System.IO;
using DXApplicationTangche.UC.项目成果管理;
using DXApplicationTangche.UC.项目成果管理.service;
using mendian;
using static mendian.Frm设计点;
using DXApplicationTangche.UC.门店下单.DTO;
using DXApplicationTangche.UC.订单.service;
using DXApplicationTangche.UC.订单一览新.改版;
using DXApplicationTangche.UC.订单一览新.辅料.辅料下单;
using DXApplicationTangche.UC.订单一览新.辅料.service;
using DXApplicationTangche.UC.生产计划.生产批生产.model;
using DXApplicationTangche.UC.全部工序.service;
using DXApplicationTangche.UC.货号管理;
using DXApplicationTangche.UC.销售台账.service;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.金蝶;
using DXApplicationTangche.UC.货号管理.service;

namespace DXApplicationTangche.UC.订单一览新.订单预览新
{
    public partial class Form订单预览新 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        #region 变量
        private String batchNo;
        private Double batchQuantiry;
        private Double wipQuantity;//  实际数量

        private Boolean urgentFlg = false;
        private Boolean 审版进入 = false;
        //private 订单基本信息 订单基本信息 = new 订单基本信息();
        //款式大类别
        private StyleCategoryDTO styleCategoryDTO = new StyleCategoryDTO();
        //辅料
        private List<ContrastForUCDto> contrastForUCDtos = new List<ContrastForUCDto>();
        //修改前判断的返回值
        private DTO返回值判断 dTO返回值判断 = new DTO返回值判断();
        //改版标识，默认false，改版为true
        private Boolean flag改版 = false;
        //private XtraUserControl辅料选择 uC辅料 = new XtraUserControl辅料选择();
        //审版的成果物：版型文件路径
        private List<String> paths = new List<string>();
        private String mnemonic { get; set; }
        private String styleNameCN { get; set; }
        private String materialNo { get; set; }
        private String paperType { get; set; }

        #endregion

        #region model
        private 订单预览新Model model;
        private 审版model 审版model = new 审版model();
        #endregion

        #region 构造函数
        public Form订单预览新(String orderId)
        {
            InitializeComponent();
            try
            {
                model = new 订单预览新Model(orderId, Enum订单查询.按照订单号查询订单);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
            this.审版();
            this.barButtonItem确认编排生产计划.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            this.barButtonItem订单打印.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
        }
        /// <summary>
        /// 改版申请一览进入
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="batchNo"></param>
        /// <param name="flag改版"></param>
        public Form订单预览新(String orderId, String batchNo,Boolean flag改版)
        {
            InitializeComponent();
            this.batchNo = batchNo;
            this.flag改版 = flag改版;
            try
            {
                model = new 订单预览新Model(orderId, Enum订单查询.按照订单号查询订单);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
            this.审版();
            this.barButtonItem订单打印.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            this.barButtonItem确认编排生产计划.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            this.barButtonItem改版.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
        }
        /// <summary>
        /// 打印订单纸
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="batchNo"></param>
        /// <param name="batchQuantiry"></param>
        /// <param name="urgentFlg"></param>
        public Form订单预览新(DTO生产批 dTO生产批)
        {
            InitializeComponent();
            this.paperType = "生产计划订单纸";
            this.batchNo = dTO生产批.batchNo;
            this.batchQuantiry = dTO生产批.batchQuantiry;
            this.wipQuantity = dTO生产批.batchQuantiry;
            this.urgentFlg = dTO生产批.urgentFlg;
            try
            {
                model = new 订单预览新Model(dTO生产批.orderId, Enum订单查询.按照订单号查询订单);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
            this.审版();
            //this.barButtonItem确认编排生产计划.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            //this.print生产计划订单纸();
        }
        public Form订单预览新(WIPPlanBatchDTO wIPPlanBatchDTO)
        {
            InitializeComponent();
            this.paperType = "生产计划订单纸";
            this.batchNo = wIPPlanBatchDTO.batchNo;
            this.batchQuantiry = wIPPlanBatchDTO.batchQuantity;
            this.wipQuantity = wIPPlanBatchDTO.wipQuantity;
            this.urgentFlg = wIPPlanBatchDTO.urgentFlg;
            try
            {
                model = new 订单预览新Model(wIPPlanBatchDTO.orderId, Enum订单查询.按照订单号查询订单);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
            this.审版();
            this.print生产计划订单纸();
            //this.barButtonItem确认编排生产计划.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
        }
        public Form订单预览新(WIPPlanBatchDTO wIPPlanBatchDTO,String openType)
        {
            InitializeComponent();
            this.paperType = "生产计划订单纸";
            this.batchNo = wIPPlanBatchDTO.batchNo;
            this.batchQuantiry = wIPPlanBatchDTO.batchQuantity;
            this.wipQuantity = wIPPlanBatchDTO.wipQuantity;
            this.urgentFlg = wIPPlanBatchDTO.urgentFlg;
            try
            {
                model = new 订单预览新Model(wIPPlanBatchDTO.orderId, Enum订单查询.按照订单号查询订单);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
            this.审版();
            //this.print生产计划订单纸();
            //this.barButtonItem确认编排生产计划.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
        }
        /// <summary>
        /// 审版，生产计划相关页面进入
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="batchNo"></param>
        /// <param name="batchQuantiry"></param>
        /// <param name="urgentFlg"></param>
        public Form订单预览新(DTO生产批 dTO生产批,String mnemonic)
        {
            InitializeComponent();
            this.审版进入 = true;
            this.batchNo = dTO生产批.batchNo;
            this.batchQuantiry = dTO生产批.batchQuantiry;
            this.mnemonic = mnemonic;
            this.urgentFlg = dTO生产批.urgentFlg;
            this.styleNameCN = dTO生产批.styleNameCn;
            this.materialNo = dTO生产批.materialCode;
            try
            {
                model = new 订单预览新Model(dTO生产批.orderId, Enum订单查询.按照订单号查询订单);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
            this.审版();
        }
        #endregion

        #region 控件事件
        private void Form订单预览新_Load(object sender, EventArgs e)
        {
            if (this.审版进入)
            {
                this.判断BOM();
            }
        }

        private void 判断BOM()
        {
            //BOM补充提示,返回值不为true时 提示补充
            SaleStyleSample saleStyleSample = 货号管理Service.getSaleStyleSampleById(this.model.OrderCommitDTO返回.styleNameCn, this.model.OrderCommitDTO返回.materialCode);
            if (saleStyleSample.bomcreated)
            {
                MessageBox.Show(this.model.OrderCommitDTO返回.styleNameCn + "--" + this.model.OrderCommitDTO返回.materialCode + " 已创建BOM清单");
            }
            else
            {
                MessageBoxButtons messBtn = MessageBoxButtons.OKCancel;
                DialogResult dr = MessageBox.Show("BOM清单为空，是否立即补充？", "提示:确认", messBtn);
                if (dr == DialogResult.OK)
                {
                    if (String.IsNullOrEmpty(this.model.OrderCommitDTO返回.materialCode))
                    {
                        return;
                    }
                    new Form金蝶EBOM保存(this.model.OrderCommitDTO返回.styleNameCn, this.model.OrderCommitDTO返回.materialCode).ShowDialog();
                }
            }
        }
        private void 页面刷新()
        {
            try
            {
                this.model.refreshOrderCommitDTO返回();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.订单信息呈现();
            this.订单基本信息呈现();
        }

        private void 订单信息呈现()
        {
            this.model.buildOrderCommit();
            this.gridControl款式.DataSource = this.model.款式DTOs;
            this.gridControl面料.DataSource = this.model.面料DTOs;
            this.gridControl备注图片.DataSource = this.model.备注DTOs;

            this.gridControl设计点.DataSource = this.model.设计点DTOs;
            this.tileView1.RefreshData();

            this.treeList尺寸.DataSource = this.model.尺寸.measureItemDTOS;
            this.treeList尺寸.ExpandAll();
            this.mianliaoname.Text = this.model.面料DTOs[0].materialNameCn;
            // 辅料uc
            //this.uC辅料 = 
            //    new XtraUserControl辅料选择(
            //        new 标识StyleAccessoryDTO(false, this.model.OrderCommitDTO返回.styleAccessoryDTOs),
            //        this.model.OrderCommitDTO返回.materialCode
            //        );
            //this.uC辅料.Dock = DockStyle.Fill;
            //this.panel辅料.Controls.Clear();
            //this.panel辅料.Controls.Add(this.uC辅料);
        }
        private void 订单基本信息呈现()
        {
            //订单基本信息
            this.textBox订单号.Text = this.model.OrderCommitDTO返回.orderNo;
            this.textBox坚山订单号.Text = this.model.OrderCommitDTO返回.kashiyamaOrderNo;
            try { this.textBox尺码.Text = this.model.OrderCommitDTO返回.styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", "");} catch { }
            this.richTextBox备注.Text = this.model.OrderCommitDTO返回.remarks;
            //订单客户信息
            this.textBox销售信息姓名.Text = this.model.OrderCommitDTO返回.customerName;
            this.textBox销售信息电话.Text = this.model.OrderCommitDTO返回.mobile;
            this.textBox发运信息姓名.Text = this.model.OrderCommitDTO返回.consignee;
            this.textBox发运信息电话.Text = this.model.OrderCommitDTO返回.mobile;
            this.model.OrderCommitDTO返回.addressProvince = this.model.OrderCommitDTO返回.addressProvince == null ? "" : this.model.OrderCommitDTO返回.addressProvince;
            this.model.OrderCommitDTO返回.addressCity = this.model.OrderCommitDTO返回.addressCity == null ? "" : this.model.OrderCommitDTO返回.addressCity;
            this.model.OrderCommitDTO返回.addressDistrict = this.model.OrderCommitDTO返回.addressDistrict == null ? "" : this.model.OrderCommitDTO返回.addressDistrict;
            this.model.OrderCommitDTO返回.addressDetail = this.model.OrderCommitDTO返回.addressDetail == null ? "" : this.model.OrderCommitDTO返回.addressDetail;
            this.model.OrderCommitDTO返回.zipCode = this.model.OrderCommitDTO返回.zipCode == null ? "" : this.model.OrderCommitDTO返回.zipCode;
            this.textBox发运信息地址.Text =
                this.model.OrderCommitDTO返回.addressProvince +
                this.model.OrderCommitDTO返回.addressCity +
                this.model.OrderCommitDTO返回.addressDistrict +
                this.model.OrderCommitDTO返回.addressDetail +
                this.model.OrderCommitDTO返回.zipCode;
        }
        private void treeList尺寸_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
        {
            try
            {
                //if (!this.flag改版)
                //{
                //    this.dTO返回值判断 = 订单Service.get订单修改判断(this.model.OrderCommitDTO返回.orderId);
                //    if (!"200".Equals(this.dTO返回值判断.errorCode))
                //    {
                //        this.页面刷新();
                //        MessageBox.Show(this.dTO返回值判断.errorMessage);
                //        return;
                //    }
                //}
                if (this.model.@enum == Enum订单类别.坚山订单 || this.model.@enum == Enum订单类别.坚山美国订单)
                {
                    this.model.尺寸.build更改尺寸for坚山(
                        this.treeList尺寸.FocusedNode["id"].ToString(),
                        e.Column.FieldName,
                        e.Value.ToString(),
                        this.model.OrderCommitDTO返回.orderId
                        );
                }
                else
                {
                    this.model.尺寸.build更改尺寸(
                        this.treeList尺寸.FocusedNode["id"].ToString(),
                        e.Column.FieldName,
                        e.Value.ToString(),
                        this.model.OrderCommitDTO返回.styleId,
                        this.model.OrderCommitDTO返回.orderId
                        );
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.treeList尺寸.DataSource = this.model.尺寸.measureItemDTOS;
            this.treeList尺寸.Refresh();
        }
        #region ribbon功能
        private void barButtonItem订单打印_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(this.model.OrderCommitDTO返回.kashiyamaOrderNo))
            {
                if (
                    销售台账Service.getKashiyamaJyutyuRecordsByProductNo(this.model.OrderCommitDTO返回.kashiyamaOrderNo).Count>0
                    )
                {
                    this.printVML订单纸();
                    return;
                }
            }
            this.print订单纸();
        }
        private void printVML订单纸()
        {
            Image pic款式 = (Image)this.tileView3.GetRowCellValue(0, "picture");
            Image pic面料 = (Image)this.tileView2.GetRowCellValue(0, "picture");
            订单导出DTO 订单导出DTO = new 订单导出DTO(this.model.OrderCommitDTO返回, pic款式, pic面料, this.batchNo, this.batchQuantiry, this.urgentFlg);
            List<订单导出DTO> 订单导出DTOs = new List<订单导出DTO>();
            订单导出DTOs.Add(订单导出DTO);
            XtraReport批次打印 report = new XtraReport批次打印();
            report.XML坚山颜色水印();
            report.DataSource = 订单导出DTOs;
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void print订单纸()
        {
            SaleOrderQueryDTO saleOrderQueryDTO = MTO下单Service.getOneSaleOrderQueryByManufactureOrderId(this.model.orderId);
            Image pic款式 = (Image)this.tileView3.GetRowCellValue(0, "picture");
            Image pic面料 = (Image)this.tileView2.GetRowCellValue(0, "picture");
            订单导出DTO 订单导出DTO = new 订单导出DTO(this.model.OrderCommitDTO返回, pic款式, pic面料, this.batchNo, this.batchQuantiry, this.urgentFlg,saleOrderQueryDTO);
            List<订单导出DTO> 订单导出DTOs = new List<订单导出DTO>();
            订单导出DTOs.Add(订单导出DTO);
            XtraReport批次打印 report = new XtraReport批次打印();
            switch (this.model.@enum)
            {
                case Enum订单类别.销售订单:
                    break;
                case Enum订单类别.坚山订单:
                    report.坚山颜色水印();
                    break;
                case Enum订单类别.坚山美国订单:
                    report.美国坚山颜色水印();
                    break;
                case Enum订单类别.坚山上海订单:
                    report.上海坚山颜色水印();
                    break;
                case Enum订单类别.样品订单:
                    report.样品颜色水印();
                    break;
                case Enum订单类别.套号订单:
                    report.套号颜色水印();
                    break;
                case Enum订单类别.Luna店铺订单:
                    report.Luna颜色水印();
                    break;
            }
            report.DataSource = 订单导出DTOs;
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }
        private void print生产计划订单纸()
        {
            SaleOrderQueryDTO saleOrderQueryDTO = MTO下单Service.getOneSaleOrderQueryByManufactureOrderId(this.model.orderId);
            Image pic款式 = (Image)this.tileView3.GetRowCellValue(0, "picture");
            Image pic面料 = (Image)this.tileView2.GetRowCellValue(0, "picture");
            订单导出DTO 订单导出DTO = new 订单导出DTO(this.model.OrderCommitDTO返回, pic款式, pic面料, this.batchNo, this.batchQuantiry, this.urgentFlg, saleOrderQueryDTO);
            if ("KASHIYAMA".Equals(订单导出DTO.CUSTOM_NAME))
            {
                订单导出DTO.SHOP_NAME = "坚山天猫";
            }
            订单导出DTO.build(this.wipQuantity);
            List<订单导出DTO> 订单导出DTOs = new List<订单导出DTO>();
            订单导出DTOs.Add(订单导出DTO);
            XtraReport生产计划订单纸 report = new XtraReport生产计划订单纸(this.wipQuantity);
            
            report.DataSource = 订单导出DTOs;
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void barButtonItem确认编排生产计划_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MessageBoxButtons messBtn = MessageBoxButtons.OKCancel;
            DialogResult dr = MessageBox.Show("确定编排生产计划？", "提示:确认", messBtn);
            if (dr == DialogResult.OK)
            {
                //  调用更改辅料接口
                //this.model.saveAccessory(this.uC辅料.build().styleAccessoryDTOs);
                //3.扫描审版人员并修改状态
                编排生产批Service.generateProductionPlanAndSaveRecord(
                    this.mnemonic, 
                    this.batchNo, 
                    "00.0001",
                    ApsConsts.REVIEW_EXECUTE,
                    this.batchNo
                    );
                MessageBox.Show("审版完成");
                this.Close();
            }
            else
            {
                return;
            }
        }

        private void barButtonItem修改辅料完成_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //// 除了改版外，修改订单前判断是否已编排生产计划
            //if (!this.flag改版)
            //{
            //    this.dTO返回值判断 = 订单Service.get订单修改判断(this.model.OrderCommitDTO返回.orderId);
            //    if (!"200".Equals(this.dTO返回值判断.errorCode))
            //    {
            //        this.页面刷新();
            //        MessageBox.Show(this.dTO返回值判断.errorMessage);
            //        return;
            //    }
            //}
            ////  调用更改辅料接口
            //this.model.saveAccessory(this.uC辅料.build().styleAccessoryDTOs);
            //MessageBox.Show("操作完成");
        }
        #endregion

        #region 审版
        private void simpleButton上传版型_Click(object sender, EventArgs e)
        {
            //上传文件
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "dgs|*.dgs;";
            ofd.Title = "请选择上传文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    订单预览新Service.post上传标准版(this.model.款式DTOs[0].refStyleId, ofd);
                    MessageBox.Show("操作成功");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.审版();
        }
        private void simpleButton下载标准版文件_Click(object sender, EventArgs e)
        {
            if (this.审版model.DTO标准版.existed)
            {
                FolderBrowserDialog sFD = new FolderBrowserDialog();
                DialogResult rdr = sFD.ShowDialog();
                string selectFileName = sFD.SelectedPath;
                if (rdr == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(selectFileName))
                {
                    try
                    {
                        //通过url下载文件
                        WebClient wClient = new WebClient();
                        wClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
                        wClient.DownloadFile(
                            URL.图片url + URL.审版路径 + this.审版model.DTO标准版.filePath, selectFileName + "\\" + Path.GetFileName(this.审版model.DTO标准版.filePath)
                            );
                        MessageBox.Show("保存成功");
                    }
                    catch
                    {
                        MessageBox.Show("保存失败");
                    }
                }
            }
            else
            {
                MessageBox.Show("未上传标准版文件");
            }
        }

        private void simpleButton上传个人版型文件_Click(object sender, EventArgs e)
        {
            //上传文件
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "dgs|*.dgs;";
            ofd.Title = "请选择上传文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    订单预览新Service.post上传个人版(this.model.OrderCommitDTO返回.customerId, this.model.OrderCommitDTO返回.refStyleId, ofd);
                    MessageBox.Show("操作成功");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.审版();
        }

        private void simpleButton下载个人版型文件_Click(object sender, EventArgs e)
        {
            if (this.审版model.DTO个人版.existed)
            {
                FolderBrowserDialog sFD = new FolderBrowserDialog();
                DialogResult rdr = sFD.ShowDialog();
                string selectFileName = sFD.SelectedPath;
                if (rdr == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(selectFileName))
                {
                    try
                    {
                        //通过url下载文件
                        WebClient wClient = new WebClient();
                        wClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
                        wClient.DownloadFile(
                            URL.图片url + URL.个人版型路径 + this.审版model.DTO个人版.filePath, selectFileName + "\\" + Path.GetFileName(this.审版model.DTO个人版.filePath)
                            );
                        MessageBox.Show("保存成功");
                    }
                    catch
                    {
                        MessageBox.Show("保存失败");
                    }
                }
            }
            else
            {
                MessageBox.Show("未上传个人版型文件");
            }
        }
        #endregion

        private void richTextBox备注_TextChanged(object sender, EventArgs e)
        {
            OrderService.ChangeOrderRemark(this.model.OrderCommitDTO返回.orderId, this.richTextBox备注.Text);
        }

        private void tileView1_ItemDoubleClick(object sender, DevExpress.XtraGrid.Views.Tile.TileViewItemClickEventArgs e)
        {
            try
            {
                if (!this.flag改版)
                {
                    this.dTO返回值判断 = 订单Service.get订单修改判断(this.model.OrderCommitDTO返回.orderId);
                    if (!"200".Equals(this.dTO返回值判断.errorCode))
                    {
                        MessageBox.Show(this.dTO返回值判断.errorMessage);
                        return;
                    }
                }
                new Frm设计点(
                    this.model.设计点DTOs[this.tileView1.FocusedRowHandle],
                    Enum选择设计点类型.全部,
                    this.model.OrderCommitDTO返回.styleId,
                    this.model.OrderCommitDTO返回.shopId,
                    "",
                    this.model.OrderCommitDTO返回.orderId
                    ).ShowDialog();
                this.页面刷新();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void barButtonItem修改地址_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            new Form更改订单收货地址(this.model.OrderCommitDTO返回).ShowDialog();
        }

        private void barButtonItem改版_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            new Form改版完成(
                    this.batchNo
                    ).ShowDialog();
        }

        
        private void 审版()
        {
            this.审版model = new 审版model(this.model.OrderCommitDTO返回);
            this.textBox标准版.Text = this.审版model.DTO标准版.filePath;
            this.textBox个人版型文件.Text = this.审版model.DTO个人版.filePath;
            this.paths.Clear();
            this.paths.Add(this.审版model.DTO标准版.filePath);
            this.paths.Add(this.审版model.DTO个人版.filePath);
        }
        #endregion
        public class DTOMeasureItemIndexComparer : IComparer<MeasureItemDTO>
        {
            public int Compare(MeasureItemDTO p1, MeasureItemDTO p2)
            {
                return p1.index.CompareTo(p2.index);
            }
        }

        private void barButtonItem订单打印新_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if ("生产计划订单纸".Equals(this.paperType))
            {
                this.print生产计划订单纸();
                return;
            }
            else if (!String.IsNullOrWhiteSpace(this.model.OrderCommitDTO返回.kashiyamaOrderNo))
            {
                if (
                    销售台账Service.getKashiyamaJyutyuRecordsByProductNo(this.model.OrderCommitDTO返回.kashiyamaOrderNo).Count > 0
                    )
                {
                    this.printVML订单纸();
                    return;
                }
            }
            this.print订单纸();
        }
    }
}